package cn.edu.scau.Servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.scau.Bean.Course;
import cn.edu.scau.Jdbc.JdbcUtils;

public class CourseServlet extends HttpServlet {
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	  
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		
		String studentId = req.getParameter("studentId");
		
		List<Course> courses = JdbcUtils.getCourse(studentId);
		
		for (int i = 0; i < courses.size(); i++) {
			
			courses.get(i).getCourseId();
		}
		
		req.getSession().setAttribute("courses", courses);
		
		resp.sendRedirect("/Tables/data/courese.jsp");
	}

}
